package com.song.day06.ch6_2;

import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.ConcurrentLinkedQueue;

public class TaskMain {
	
	
	
	public static void main(String[] args) {
		ConcurrentLinkedDeque<String> list = new ConcurrentLinkedDeque<>();
		Thread threads[] = new Thread[100];
		
		for(int i =0; i<threads.length ;i++)
		{
			AddTask task = new AddTask(list);
			threads[i] = new Thread(task);
			threads[i].start();
		}
		
		System.out.printf("Main : %d AddTask threads have been launched \n", threads.length);
		
		for(int i =0;i<threads.length ;i++)
		{
			try {
				threads[i].join();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		System.out.printf("Main :size of the List %d \n",list.size());
		
		for(int i =0 ;i<threads.length ;i++)
		{
			PollTask task = new PollTask(list);
			threads[i] = new Thread(task);
			threads[i].start();
		}
		System.out.printf(" Main  %d PollTask Threads have been launched \n",threads.length);
		
		for(int i=0;i<threads.length;i++)
		{
			try {
				threads[i].join();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		System.out.printf(" Main :size of the list size %d \n", list.size());
	}
	
}
